namespace CookieTerm.MdiTabStrip
{

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    public partial class MdiTabStripDesignerForm
    {
        private MdiTabTemplateControl withEventsField__template;
        private MdiTabTemplateControl _template
        {
            get { return withEventsField__template; }
            set
            {
                if (withEventsField__template != null)
                {
                    withEventsField__template.TabSelected -= _template_TabSelected;
                }
                withEventsField__template = value;
                if (withEventsField__template != null)
                {
                    withEventsField__template.TabSelected += _template_TabSelected;
                }
            }

        }
        public MdiTabTemplateControl TabTemplate
        {
            get { return _template; }
            set
            {
                _template = value;

                _template.Location = new Point(this.SplitContainer1.Panel1.Width / 2 - _template.Width / 2, this.SplitContainer1.Panel1.Height / 2 - _template.Height / 2);
                this.SplitContainer1.Panel1.Controls.Clear();
                this.SplitContainer1.Panel1.Controls.Add(value);
                this.PropertyGrid1.SelectedObject = _template.ActiveTabTemplate;
            }
        }

        private void cboTabType_SelectedValueChanged(object sender, System.EventArgs e)
        {
            if (_template != null)
            {
                if ((string) cboTabType.SelectedItem == "Active Tab")
                {
                    this.PropertyGrid1.SelectedObject = _template.ActiveTabTemplate;
                }
                else if ((string) cboTabType.SelectedItem == "Inactive Tab")
                {
                    this.PropertyGrid1.SelectedObject = (object) _template.InactiveTabTemplate;
                }
                else
                {
                    this.PropertyGrid1.SelectedObject = _template.MouseOverTabTemplate;
                }
            }
        }

        private void _template_TabSelected(TabSelectedEventArgs e)
        {
            if (e.TabType == TabType.Active)
            {
                cboTabType.SelectedItem = "Active Tab";
            }
            else if (e.TabType == TabType.Inactive)
            {
                cboTabType.SelectedItem = "Inactive Tab";
            }
            else
            {
                cboTabType.SelectedItem = "Mouseover Tab";
            }
        }
    }

    //=======================================================
    //Service provided by Telerik (www.telerik.com)
    //Conversion powered by NRefactory.
    //Twitter: @telerik
    //Facebook: facebook.com/telerik
    //=======================================================
}